<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%attribute_value}}".
 *
 * @property integer $vid
 * @property integer $attr_id
 * @property string $value
 * @property integer $order
 */
class AttributeValue extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%attribute_value}}';
    }

    public function transactions()
    {
        return [
            self::OP_ALL
        ];
    }


    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['attr_id'], 'required'],
            [['attr_id', 'order'], 'integer'],
            [['value'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'vid' => '属性值id',
            'attr_id' => '属性id',
            'value' => '属性值',
            'order' => '排序',
        ];
    }

    public function getAttr()
    {
        return $this->hasOne(Attribute::className(), ['id' => 'attr_id']);
    }
}
